package graphic.primitives.car;

import graphic.primitives.general.GraphicObject;
import graphic.primitives.general.IGraphicObject;
import java.awt.Color;

/**
 *
 * @author Tomas Zima
 */
public class Doors extends GraphicObject implements IGraphicObject
{
	public Doors(int x, int y, int a, int b, int c)
	{
		this.setXY(x, y);
		
		this.a = a;
		this.b = b;
		this.c = c;

	}
	
	@Override
	public void redraw()
	{
		// vybarveni
		//mainWindow.setColor(new Color(0.7f, 0.0f, 0.0f));
		mainWindow.setColor(new Color(0.6f, 0.0f, 0.0f));
		
		for (int i = 0; i < a; i++)
		{
			mainWindow.line(x + i, y, x + i, y - c);
		}
		mainWindow.setColor(Color.BLACK);
		
		mainWindow.line(x, y, x + a, y); // spodek 
		//mainWindow.line(x, y - b, x + a, y - b); // neni nutne (prekryva)
		mainWindow.line(x, y, x, y - b); // leva dolni strana
		mainWindow.line(x + a, y, x + a, y - b); // prava dolni strana 
		mainWindow.line(x, y - c, x + a, y - c); // horizontalni	
		mainWindow.line(x, y + c/4, x + a, y + c/4); // horizontalni

		mainWindow.line(x, y - c - (b / 2 * windowState / 100), x + a, y - c - (b / 2 * windowState / 100)); // horizontalni	
		

	}
	
	public void set(int state)
	{
		this.windowState = state;
	}
	
	public void down()
	{
		windowState -= jump;
		
		if (windowState < 0)
		{
			windowState = 0;
		}
	}
	
	public void up()
	{
		windowState += jump;
		
		if (windowState > 100)
		{
			windowState = 100;
		}
	}
	
	private int a;
	private int b;
	private int c;
	
	private int windowState = 100;
	
	private final int jump = 5;
}
